/* this module implements a FIFO queue of pointers on PCB. It is mainly used by the I/O devices. */

#ifndef PCB_FIFO_QUEUE_H
#define PCB_FIFO_QUEUE_H

#include "process_management.h"
#include "types.h"


#define MAX_QUEUE_LENGTH NUMBER_MAX_PROCESSES

/* type declaration */

typedef struct {
  PCB* queue[MAX_QUEUE_LENGTH];
  int32_t count;
  int32_t in;
  int32_t out;
}pcb_fifo_queue_t;


/* function declarations */

/* resets the queue fifo */
void pcb_fifo_queue_reset(pcb_fifo_queue_t* fifo);

/* puts the PCB pcb at the end of the queue. Returns 1 if success or 0 if the queue is full */
int32_t pcb_fifo_queue_put(pcb_fifo_queue_t* fifo, PCB* pcb);

/* returns the head of the queue and removes it. Returns NULL if the queue is empty */
PCB* pcb_fifo_queue_get(pcb_fifo_queue_t* fifo);

/* removes the process pcb from the queue fifo. Returns 1 in case of success, 0 otherwise */
int32_t pcb_fifo_queue_remove(pcb_fifo_queue_t* fifo, PCB* pcb);

#endif
